package com.box.quartz;

import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.box.service.LogService;
import com.box.utils.DateUtil;



/**   
*    
* 项目名称：MyBox   
* 类名称：MethodLogQuartz   
* 类描述：   清除系统日志任务
* 创建人：君无邪   
* 创建时间：2019年11月22日 上午1:02:13   
* 修改备注：  https://www.java214.com 
* @version    1.0
*    
*/ 
@Component
public class MethodLogQuartz {
	
	 private static Logger LOGGER = Logger.getLogger(MethodLogQuartz.class);
	    private static final Integer LOGDAYS = 30;

	    @Autowired
	    private LogService logServiceImpl;
	    
	    @Scheduled(cron="0 0 23 * * ?")
	    public void clearLog() {
	        Integer logDays = LOGDAYS ;
	        Date date = DateUtil.getDate(DateUtil.getDate(), -logDays);
	        int count =logServiceImpl.delLogsByDate(date);
	        LOGGER.info("日志定时删除任务，删除日志数量:" + count + ", createDate < "
	                + DateUtil.getStringDate(date, DateUtil.DateFormat1));
	    }

}
